import modelExtend from 'dva-model-extend'
import { parse } from 'qs'
import { pageModel } from './common'
import { myCity, queryWeather, query } from 'services/dashboard'


export default modelExtend(pageModel, {
  namespace: 'dashboard',
  state: {
    numbers: [],
    sumList:[],
    countList:[],
  },
  subscriptions: {
    setup ({ dispatch, history }) {
      history.listen((location) => {
        if (location.pathname === '/dashboard') {
          dispatch({
            type: 'query',
            payload: location.query,
          })
        }
      })
    },
  },
  effects: {
    * query ({
      payload,
    }, { call, put }) {
      //const data = yield call(query, parse(payload))
      const numbers=[
          {icon: "red-envelope", color: "#f50", title: "销售额", number: 2781},
          {icon: "user-add", color: "#8fc9fb", title: "新增用户", number: 3241},
          {icon: "shopping-cart", color: "#d897eb", title: "订单数", number: 253},
          {icon: "car", color: "#f69899", title: "待配送", number: 4324},
        ]
      yield put({ 
        type: 'updateState', 
        payload: { 
          numbers:numbers,
        } 
      })
    },
  },
  reducers: {
   
  },
})
